package cloud.daodao.storm.dict.controller;

import cloud.daodao.storm.dict.service.CodeMapService;
import cloud.daodao.storm.common.dict.api.CodeMapApi;
import cloud.daodao.storm.common.dict.model.codemap.CodeMapData;
import cloud.daodao.storm.common.dict.model.codemap.CodeMapSearch;
import cloud.daodao.storm.common.dict.model.codemap.CodeMapSelect;
import cloud.daodao.storm.common.dict.model.codemap.CodeMapUpsert;
import cloud.daodao.storm.common.model.PageData;
import cloud.daodao.storm.common.model.PageParam;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DaoDao
 */
@RestController
public class CodeMapController implements CodeMapApi {

    @Resource
    private CodeMapService codeMapService;

    @Override
    public Response<CodeMapData> codeMapSelect(@RequestBody @Valid Request<CodeMapSelect> request) {
        CodeMapData data = codeMapService.codeMapSelect(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<CodeMapData> codeMapUpsert(@RequestBody @Valid Request<CodeMapUpsert> request) {
        CodeMapData data = codeMapService.codeMapUpsert(request.getParam());
        return new Response<>(data);
    }

    @Override
    public Response<PageData<CodeMapData>> codeMapSearch(@RequestBody @Valid Request<PageParam<CodeMapSearch>> request) {
        PageData<CodeMapData> data = codeMapService.codeMapSearch(request.getParam());
        return new Response<>(data);
    }

}
